<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>个人资料--layui后台管理模板 2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/favicon.ico">
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/login.css" media="all">
</head>
<body class="childrenBody">
<form action="" method="post" class="layui-form layui-form-pane" id="dataFrm" lay-filter="dataFrm">
    <div class="layui-col-md6 layui-col-xs12">
        <div class="layui-col-md3 layui-col-xs12 user_right">
            <div class="layui-upload-list">
                <img class="layui-upload-img layui-circle userFaceBtn userAvatar" id="userFace">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">用户姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" id="username" lay-verify="required" autocomplete="off"
                           placeholder="请输入用户姓名" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">用户邮箱</label>
                <div class="layui-input-inline">
                    <input type="text" name="email" id="email" lay-verify="required" autocomplete="off"
                           placeholder="请输入用户邮箱" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">登陆名称</label>
            <div class="layui-input-block">
                <input type="hidden" name="id">
                <input type="text" name="loginname" autocomplete="off" placeholder="请输入用户用地址" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" style="text-align: center;">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="doSubmit"><span
                        class="layui-icon layui-icon-add-1"></span>提交
                </button>
                <button type="reset" class="layui-btn layui-btn-warm"><span
                        class="layui-icon layui-icon-refresh-1"></span>重置
                </button>
            </div>
        </div>
    </div>
</form>
<script src="/plugins/layui/layui.js"></script>
<script src="/plugins/layui/layui.all.js"></script>
<script type="text/javascript">
    var tableIns;
    layui.extend({
        dtree: '/resources/layui_ext/dtree/dtree'   // {/}的意思即代表采用自有路径，即不跟随 base 路径
    }).use(['jquery', 'form', 'table', 'layer'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var table = layui.table;
        var layer = layui.layer;

        $.post("/staff/loadCurrentStaff", function (res) {
            var data = res.data;
            console.log('res.data--->' + res.data);
            $("#dataFrm")[0].reset();
            //装载新的数据
            form.val("dataFrm", data);
            url = "/staff/updateStaff";
        });

        form.on("submit(doSubmit)", function (data) {
            console.log(data.field);
            $.post(url, data.field, function (res) {
                if (res.code === 1) {
                    layer.msg("修改成功", {icon: 1}, function () {
                        parent.layer.closeAll()
                    })
                } else {
                    layer.msg(res.msg);
                }
            })
            return false;
        });
    });
</script>
</body>
</html>